package com.bancomer.batch.validators.impl;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;

import com.bancomer.batch.pojo.FileHelper;
import com.bancomer.batch.pojo.ValidationResult;
import com.bancomer.batch.validators.GeneralValidator;

public class EmptyFileValidator implements GeneralValidator {

	@Override
	public ValidationResult executeValidation(FileHelper fileHelper,
			Object... obj) {
		ValidationResult result = new ValidationResult();
		String completeFileName = fileHelper.getLocalPath()+fileHelper.getName();
		File fileOfficeType = new File(completeFileName);
		if(fileOfficeType.exists()==false){
			PrintWriter writer;
			try {
				writer = new PrintWriter(completeFileName, "UTF-8");
				writer.close();
			} 
			catch (Exception e) {
				// TODO Auto-generated catch block
				result.setMessage("Class: EmptyFileValidator - "+e.getMessage());
				result.setSucces(false);
			}
		}
		// TODO Auto-generated method stub
		return result;
	}

}
